﻿#region License

// // -------------------------------------------------------------------------------------
// // This information refers to Configuration.cs
// // 
// // Copyright 2012 ELEN7046 Group 2
// // 
// // Last Modified on: 2012-06-10
// // 
// // Contributors:
// // 
// // Amith Sewnarain
// // Elmar Vosloo
// // Jason Thorne
// // Satish Jewan
// // 
// // Wits University 
// // School of Electrical & Information Engineering
// // Software Engineering Tools and Techniques
// // 
// // -------------------------------------------------------------------------------------
// // 
// // This file (Configuration.cs) is part of the DishDash Event Visualization System.
// // 
// // DishDash is free software: you can redistribute it and/or modify
// // it under the terms of the GNU General Public License as published by
// // the Free Software Foundation, either version 3 of the License, or
// // (at your option) any later version.
// // 
// // DishDash is distributed in the hope that it will be useful,
// // but WITHOUT ANY WARRANTY; without even the implied warranty of
// // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// // GNU General Public License for more details.
// // 
// // You should have received a copy of the GNU General Public License
// // along with DishDash.  
// // If not, see <http://www.gnu.org/licenses/>.
// // -------------------------------------------------------------------------------------

#endregion

#region Using Directives

using System.Configuration;

#endregion

namespace LogOneDayPrecisionApp
{
    /// <summary>
    ///   Configuration for this handler.
    /// </summary>
    public class Configuration : ConfigurationSection
    {
        private const string sectionName = "dishdash.handler";

        private const string exchangeName = "exchangeName";
        private const string queueName = "queueName";
        private const string host = "host";
        private const string user = "user";
        private const string password = "password";

        private static Configuration instance;

        /// <summary>
        /// Prevents a default instance of the <see cref="Configuration"/> class from being created.
        /// </summary>
        private Configuration()
        {
        }

        /// <summary>
        ///   Gets an instance of the configuration for this handler service.
        /// </summary>
        /// <value> The instance. </value>
        public static Configuration Instance
        {
            get
            {
                if (instance == null)
                {
                    instance =
                        ConfigurationManager.GetSection(sectionName)
                        as Configuration;
                }

                return instance;
            }
        }

        /// <summary>
        ///   Gets or sets the name of the exchange.
        /// </summary>
        /// <value> The name of the exchange. </value>
        [ConfigurationProperty(exchangeName, IsRequired = true)]
        public string ExchangeName
        {
            get { return base[exchangeName] as string; }
            set { base[exchangeName] = value; }
        }

        /// <summary>
        ///   Gets or sets the name of the queue.
        /// </summary>
        /// <value> The name of the queue. </value>
        [ConfigurationProperty(queueName, IsRequired = true)]
        public string QueueName
        {
            get { return base[queueName] as string; }
            set { base[queueName] = value; }
        }

        /// <summary>
        ///   Gets or sets RabbitMQ host name.
        /// </summary>
        /// <value> The host. </value>
        [ConfigurationProperty(host, IsRequired = false, DefaultValue = "localhost")]
        public string Host
        {
            get { return base[host] as string; }
            set { base[host] = value; }
        }

        /// <summary>
        ///   Gets or sets RabbitMQ user name.
        /// </summary>
        /// <value> The user. </value>
        [ConfigurationProperty(user, IsRequired = false, DefaultValue = "guest")]
        public string User
        {
            get { return base[user] as string; }
            set { base[user] = value; }
        }

        /// <summary>
        /// Gets or sets the password.
        /// </summary>
        /// <value>
        /// The password.
        /// </value>
        [ConfigurationProperty(password, IsRequired = false, DefaultValue = "")]
        public string Password
        {
            get { return base[password] as string; }
            set { base[password] = value; }
        }
    }
}